home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / can.zip / ECAN.ASM < prev    next >
Assembly Source File  |  1994-02-16  |  1KB  |  42 lines

  1. ;
  2. ; Embedded function for the CAN utility.
  3. ;
  4. ; Copyright 1990 Dave Dunfield.
  5. ;
  6. ; May be freely distributed and used as long as
  7. ; my copyright notices are retained.
  8. ;
  9. DGRP    GROUP    DSEG
  10. DSEG    SEGMENT    BYTE PUBLIC 'IDATA'
  11. DSEG    ENDS
  12. CSEG    SEGMENT    BYTE PUBLIC 'CODE'
  13.         ASSUME    CS:CSEG, DS:DGRP, SS:DGRP
  14.         PUBLIC    _CAN_S, _CAN_E
  15. ;
  16. ; Embedded CAN function, appends arguments to the PSP,
  17. ; and then restores & jumps to the original code.
  18. ;
  19. _CAN_S:    MOV        BX,0080h            ; Get offset of Command Tail
  20.         ADD        BL,[BX]                ; Get length
  21.         INC        BX                    ; Skip length byte
  22. ; Copy in the "permanent" operands
  23. can1:    MOV        AL,[SI]                ; Get value
  24.         MOV        [BX],AL                ; Write it out
  25.         INC        SI                    ; Skip to next source
  26.         INC        BX                    ; Skip to next dest
  27.         CMP        AL,0Dh                ; End of line?
  28.         JNZ        can1                ; No, keep going
  29.         SUB        BL,82h                ; Convert to actual length
  30.         MOV        DS:0080h,BL            ; Set new length
  31. ; Now... restore the original startup code, and execute it
  32.         MOV        BX,0100h            ; Point to start of code
  33.         MOV        AX,[SI]                ; Get first two bytes
  34.         MOV        [BX],AX                ; Replace it
  35.         MOV        AL,2[SI]            ; Get last byte
  36.         MOV        2[BX],AL            ; Replace it
  37.         JMP        BX                    ; And execute
  38. _CAN_E:
  39. ;
  40. CSEG    ENDS
  41.         END
  42.